package utils;

import java.util.Collection;

/**
 * 字符串工具
 * 
 * @author ultrafrog
 * @version 1.0, 2015-04-06
 * @since 1.0
 */
public abstract class Strings {

	/**
	 * 空判断
	 * 
	 * @param value
	 * @return
	 */
	public static boolean empty(String value) {
		return (value == null || value.length() == 0);
	}
	
	/**
	 * 空判断<br>
	 * 若为空则返回默认值
	 * 
	 * @param value
	 * @param defaultValue
	 * @return
	 */
	public static String empty(String value, String defaultValue) {
		return empty(value) ? defaultValue : value;
	}
	
	/**
	 * 合并
	 * 
	 * @param objs
	 * @param symbol
	 * @return
	 */
	public static String implode(Collection<?> objs, String symbol) {
		StringBuffer buffer = new StringBuffer(32);
		for (Object obj: objs) buffer.append(symbol).append(obj.toString());
		return buffer.substring(symbol.length());
	}
}
